#include "StateUpdateCallback.h"
#include <fstream>
#include <string>



namespace Estimator
{

ceres::CallbackReturnType StateUpdateCallback::operator()(const ceres::IterationSummary &summary)
{

    if (log_to_stdout_)
    {
        std::cout << "StateUpdateCallback operator(): Update success: " << mpOptimizer_->NumberofPoses() << std::endl;
    }

    // std::string filename = mFolderName_ + "/" + std::to_string(summary.iteration) + ".txt";

    // std::fstream file(filename, std::fstream::out | std::fstream::trunc);
    // // mpOptimizer_->WriteResult();

    // for (auto ite = mpOptimizer_->mvPoseBlock.cbegin(); ite != mpOptimizer_->mvPoseBlock.cend(); ++ite)
    // {
    //     file << (*ite).GetId() << " ";
    //     for (size_t j = 0; j < 12; ++j)
    //     {
    //         file << *((*ite).parameters() + j) << " ";
    //     }
    //     file << std::endl;
    // }

    // file.close(); 

    return ceres::SOLVER_CONTINUE;
}
}